<template>
  <a-card
    :loading="loading"
    :body-style="{ padding: '20px 24px 8px' }"
    :bordered="false"
  >
    <div class="chart-card-header">
      <div class="meta">
        <span class="chart-card-title">{{ title }}</span>
        <span class="chart-card-action">
          <slot name="action"></slot>
        </span>
      </div>
      <div class="total">
        <span>{{ total }}</span
        ><img v-if="imgtype !== 5"
          :src="
            imgtype == 1
              ? img
              : imgtype == 2
              ? img1
              : imgtype == 3
              ? img2
              : imgtype == 4
              ? img3 : ''
          "
          style="width: 60px;height: 60px;"
          alt=""
        />
      </div>
    </div>
    <div class="chart-card-content">
      <div class="content-fix">
        <slot></slot>
      </div>
    </div>
    <div class="chart-card-footer">
      <div class="field">
        <slot name="footer"></slot>
      </div>
    </div>
  </a-card>
</template>

<script>
export default {
  name: "ChartCard",
  props: {
    title: {
      type: String,
      default: "",
    },
    total: {
      type: String,
      default: "",
    },
    loading: {
      type: Boolean,
      default: false,
    },
    imgtype: {
      type: Number,
      default: "",
    },
  },
  data() {
    return {
      img: require("../assets/home_img/yonhu.png"),
      img1: require("../assets/home_img/tabi.png"),
      img2: require("../assets/home_img/zhuanjia.png"),
      img3: require("../assets/home_img/zhuanjia(1).png"),
    };
  },
};
</script>

<style lang="less" scoped>
.chart-card-header {
  position: relative;
  overflow: hidden;
  width: 100%;

  .meta {
    position: relative;
    overflow: hidden;
    width: 100%;
    // color: rgba(0, 0, 0, .45);
    font-size: 14px;
    line-height: 22px;
    .chart-card-title {
      font-size: 16px;
      font-family: Microsoft YaHei, Microsoft YaHei;
      font-weight: 400;
      color: rgba(255, 255, 255, 0.8);
    }
  }
}

.chart-card-action {
  cursor: pointer;
  position: absolute;
  top: 0;
  right: 0;
}

.chart-card-footer {
  // border-top: 1px solid #e8e8e8;
  padding-top: 9px;
  margin-top: 8px;

  > * {
    position: relative;
  }

  .field {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
  }
}

.chart-card-content {
  margin-bottom: 12px;
  position: relative;
  height: 46px;
  width: 100%;
  font-size: 16px;
  font-family: Microsoft YaHei, Microsoft YaHei;
  font-weight: 400;
  color: #ffffff;
  .content-fix {
    position: absolute;
    left: 0;
    bottom: 0;
    width: 100%;
  }
}

.total {
  // overflow: hidden;
  font-family: Microsoft YaHei, Microsoft YaHei;
  display: flex;
  justify-content: space-between;
  text-overflow: ellipsis;
  word-break: break-all;
  white-space: nowrap;
  color: #ffffff;
  margin-top: 4px;
  margin-bottom: 0;
  font-size: 30px;
  font-weight: bold;
  line-height: 56px;
  height: 38px;
}
</style>
